from core.api_util import api_util
from utils.response_util import process_response


def mobile_query(params):
    res = api_util.get_mobile_belong(params=params)
    return process_response(res)


def search_douban(params):
    res = api_util.search_douban(params=params)
    return process_response(res)


def send_code(json_data):
    res = api_util.send_code(json=json_data)
    return process_response(res)


def register_mobile(code, mobile):
    json_data = {
        "code": str(code),
        "password": "123456",
        "username": str(mobile)
    }
    res = api_util.register_mobile(json=json_data)
    return process_response(res)


def user_login(username, password):
    json_data = {"username": str(username), "password": str(password)}
    res = api_util.user_login(json=json_data)
    return process_response(res)


def get_banner():
    res = api_util.get_banner()
    return process_response(res)


def add_shop_car(json_data, token):
    headers = {"Authorization": "JWT " + str(token)}
    res = api_util.add_shop_car(json=json_data, headers=headers)
    return process_response(res)


def add_message(data, files, token):
    headers = {"Authorization": "JWT " + str(token)}
    res = api_util.add_message(data=data, headers=headers, files=files)
    return process_response(res)
